package cool.taomu.demo

import cool.taomu.demo.entity.sina.SinaStock
import cool.taomu.demo.entity.sina.StockIndustryDataEntity
import cool.taomu.demo.entity.sina.StockIndustryEntity
import cool.taomu.demo.utils.ListPageUtils
import cool.taomu.demo.utils.StockDataUtils

class SinaStockDataService {
	def static getStockIndustryList() {
		/*val h2 = StockDataUtils.getInstance().getH2();
		var industrys = h2.select("select industry from stock_data group by industry order by industry desc",Map);
		val indlist = newArrayList();
		industrys.forEach [
			var ind = it.get("INDUSTRY") as String
			var stock = h2.select("select code from stock_data where INDUSTRY=?",Map, #[ind]);
			var codes = stock.map [
				return it.get("CODE") as String;
			]
			var String indKey = ind.nullOrEmpty ? "其他" : ind;
			var sie = new StockIndustryEntity(indKey, codes);
			var pageSize = sie.codes.size / 800;
			val stocklist = newArrayList;
			val codelist = newArrayList();
			for (i : 0 .. pageSize) {
				ListPageUtils.page(i + 1, 800, sie.codes, [ j, v |
					codelist.add(v);
				])
				var code = codelist.join(",").replace(".", "");
				var res = SinaStock.getStockData(code);
				stocklist.addAll(res);
				codelist.clear();
			}
			indlist.add(new StockIndustryDataEntity(indKey, stocklist));
		];
		return indlist;*/
	}
}
